﻿using System;
using System.Collections.Generic;
using GameEngine.View.Components;
using PureMVC.Interfaces;
using PureMVC.Patterns;

namespace GameEngine.View
{
    public class MenuMediator<Type, View> : Mediator
        where View : class, IMenuView<Type>
    {
        string CommandName;

        public MenuMediator(String name, View viewComponent, string outCommand)
            : base(name, viewComponent)
        {
            CommandName = outCommand;
            viewComponent.OnExternalActionButtonClick += OnButtonClick;
        }

        public new View ViewComponent {
            get { return base.ViewComponent as View;  }
        }

        #region IMediator Members

        /// <summary>
        /// List the <c>INotification</c> names this <c>Mediator</c> is interested in being notified of
        /// </summary>
        /// <returns>The list of <c>INotification</c> names </returns>
        override public IList<string> ListNotificationInterests()
        {
            return new List<string>();
        }

        /// <summary>
        /// Handle <c>INotification</c>s
        /// </summary>
        /// <param name="notification">The <c>INotification</c> instance to handle</param>
        /// <remarks>
        ///     <para>
        ///        Typically this will be handled in a switch statement, with one 'case' entry per <c>INotification</c> the <c>Mediator</c> is interested in. 
        ///     </para>
        /// </remarks>
        override public void HandleNotification(INotification notification)
        {
        }

        /// <summary>
        /// Called by the View when the Mediator is registered
        /// </summary>
        override public void OnRegister()
        {
        }

        /// <summary>
        /// Called by the View when the Mediator is removed
        /// </summary>
        override public void OnRemove()
        {
        }

        #endregion

        private void OnButtonClick(Type text)
        {
            SendNotification(CommandName, text);
        }
    }
}
